<?php 
/**
 * @package      App_Sample
 * @copyright    Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version      $Id: LogDb.php 130 2011-03-18 03:10:02Z cheng.wei $
 */
class WalkathonLog extends Zend_Db_Table {
	 protected $_name = 'walkathon_log';
};
class Zend_Log_Writer_LogDb{
	
	public function insertLogData($Backend_AdministratorController ,$response ,array $arr = array())
	{
//		var_dump($module,$action,$_POST,$_SESSION,$_REQUEST['usernamecook'],getenv('REMOTE_ADDR'));die;
//		if(!empty($_POST))	
//		{
//			if(in_array($module ,array('backend')))
//			{
//				if(in_array($action,array('add', 'delete', 'save-edit', 'saveEdit')))
//				{
//					$table = new WalkathonLog();
//						$data = array(
//					    'username' => $_REQUEST['usernamecook'],
//					    'time'  => time(),
//					    'ip' => getenv('REMOTE_ADDR'),
//					    'time'  => date('Y-m-d H:i:s',time()),
//					    'operate_type'  => $action
//					);
//					
//					$id = $table->insert($data);
//					
//				}//action end
//			}
//		}//post end
		$action = $Backend_AdministratorController->getRequest()->getActionName();
		$controller = $Backend_AdministratorController->getRequest()->getControllerName();
		$module = $Backend_AdministratorController->getRequest()->getModuleName();
		$operate_flag = $Backend_AdministratorController->operate_flag;
		$usernamecook = $_REQUEST['usernamecook'];
		//		$id = Zend_Auth::getInstance()->getIdentity()->getId();
		//var_dump($response);die;
		//		var_dump($action,$controller,$module,$operate_flag,$usernamecook,$id);
		if($arr['by_email'])
		{
			$controller = 'email';
		}
		$table = new WalkathonLog();
			$data = array(
		    'username' => $_REQUEST['usernamecook'],
		    'time'  => time(),
		    'ip' => getenv('REMOTE_ADDR'),
		    'time'  => date('Y-m-d H:i:s',time()),
		    'operate_act'  => $action,
			'operate_mol'  => $module,
			'operate_con'  => $controller,
		    'operate_id' => $response->getData('id'),
			'operate_succeed' => (intval($response->hasDataChanges()) > 0 ? 'yes' : 'no')
		);
		
		$id = $table->insert($data);
		
	}
}
?>